<template>
<h2>添加房号表</h2>
<table border="1">
    <tr>
        <td>房号名称</td>
        <td>
            <input type="text" v-model="info.Rnumber_Name">
        </td>
    </tr>
    <tr>
        <td>楼层</td>
        <td>
            <input type="number" v-model="info.Rnumber_Floor">
        </td>
    </tr>
    <tr>
        <td>具体房间号</td>
        <td>
            <input type="text" v-model="info.Rnumber_Num">
        </td>
    </tr>
    <tr>
        <td>房号状态</td>
        <td>
            <input type="radio" :value="true" v-model="info.Rnumber_State">空房可住
            <input type="radio" :value="false" v-model="info.Rnumber_State">已有入住
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button" value="保存" @click="SaveData">
        </td>
    </tr>
   
</table>

</template>
<script setup lang="ts">
import axios from "axios";
import { onMounted ,ref} from "vue";


const info=ref({
 
  Rnumber_Name: "",
  Rnumber_Floor: "",
  Rnumber_Num: "",
  Rnumber_State: true,
  


})


const SaveData=()=>{

    if(info.value.Rnumber_Name==""){
        alert("房号表名称不能为空");
        return;
    }

    axios.post('https://localhost:7153/api/T_RoomNumber/AddRoomNumber',info.value)
    .then(res=>{
        if(res.data==-1){
            alert("房号表名称已经存在");
        }
        else if(res.data>0){
            alert("添加成功");
        }
        else{
            alert("添加失败");
        }


    })


}




</script>